﻿using System.Device.Location;
using System.Windows;
using GalaSoft.MvvmLight;

namespace MyMeetup.ViewModels
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm/getstarted
    /// </para>
    /// </summary>
    public class MapViewModel : ViewModelBase
    {
        /// <summary>
        /// Initializes a new instance of the MapViewModel class.
        /// </summary>
        public MapViewModel()
        {
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real": Connect to service, etc...
            ////}
        }

        public MapViewModel(double latitude, double longitude)
        {
            Latitude = latitude;
            Longitude = longitude;
        }

        public override void Cleanup()
        {
            // Clean own resources if needed

            base.Cleanup();
        }


        public string Title { get; set; }

        public Visibility PushPinVisibility
        {
            get { return (Longitude != 0 && Latitude != 0) ? Visibility.Visible : Visibility.Collapsed; }
        }


        public int Zoom
        {
            get
            {
                return (Longitude != 0 && Latitude != 0) ? 12 : 2;
            }
        }

        public GeoCoordinate MapCenter
        {
            get { return new GeoCoordinate(Latitude, Longitude); }
        }

        public double Latitude { get; set; }
        public double Longitude { get; set; }
    }
}